from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.touch_action import TouchAction
from time import sleep
caps = {}
# 设置app的包名
caps["appPackage"] = "com.threegene.doctor"
# 设置app的启动Activity
caps["appActivity"] = ".module.splash.SplashActivity"
# 设置设备系统版本
caps["platformVersion"] = "7.1.2"
# 设置设备系统名称
caps["platformName"] = "Android"
# 设置设备名
caps["deviceName"] = "dream2lteks"

driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
# 设置隐式等待时间为15秒
driver.implicitly_wait(15)

# 定义一个函数，用于点击屏幕上的某个位置
TouchAction(driver).tap(x=64, y=612).perform()
sleep(5)
el0 = driver.find_element(MobileBy.ID,"com.threegene.doctor:id/agree_user_agreement_btn")#点击同意
el0.click()
sleep(2)
TouchAction(driver).press(x=674, y=762).move_to(x=35, y=705).release().perform() #滑动1
sleep(2)
TouchAction(driver).press(x=639, y=786).move_to(x=46, y=739).release().perform() #滑动2
sleep(2)
el1 = driver.find_element(MobileBy.ID,"com.threegene.doctor:id/submit_btn") #点击立即体验
el1.click()
el2 = driver.find_element(MobileBy.ID,"com.threegene.doctor:id/cb_agree")#点击阅读
el2.click()
sleep(2)
el3 = driver.find_element(MobileBy.ID,"com.threegene.doctor:id/tv_phone_login") #点击手机登录
el3.click()
sleep(2)
el4 = driver.find_element(MobileBy.ID,"com.threegene.doctor:id/edit_phone_number")#点击手机号输入框
sleep(2)
el4.send_keys("13940114587")
sleep(2)
el5 = driver.find_element(MobileBy.ID,"com.threegene.doctor:id/tv_send_code") #点击获取验证码
el5.click()

